package io2.nio;

import java.nio.ByteBuffer;

public class ByteBufferDemo {
    public static void main(String[] args) {
        // 在使用byte数组转换为ByteBuffer的时候，也是零拷贝的。直接使用了byte数组来存储数据
        byte[] bytes = {1, 2, 3, 4, 5};
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        System.out.println("byteBuffer -> " + byteBuffer);
        System.out.println("byteBuffer.get3 -> " + byteBuffer.get(3));
        bytes[3] = 0;
        System.out.println("byteBuffer.get3 -> " + byteBuffer.get(3));
    }
}
